class Solution:
    def closeStrings(self, s: str, t: str) -> bool:
        return len(s) == len(t) and \
               set(s) == set(t) and \
               Counter(Counter(s).values()) == Counter(Counter(t).values())


class Solution:
    def closeStrings(self, s: str, t: str) -> bool:
        if len(s) != len(t):
            return False
        cs, ct = Counter(s), Counter(t)
        return cs.keys() == ct.keys() and Counter(cs.values()) == Counter(ct.values())
